import {app_scret} from "../config";

const moment = require("moment")
var jwt = require('jwt-simple');
var expires = moment().add('hours', 1).valueOf()

export function decodeAndCreateToken(user) {
    var token = jwt.encode(user, app_scret);
    return token
}

export function validateToken(token) {
    return new Promise((resolve, reject) => {
       var payload= jwt.decode(token, app_scret)
        if(!payload){
            reject("没有")
        }else{
            resolve(payload)
        }
    })


}
